package gem.model.dao;

import gem.model.dao.mysql.MySqlDAOFactory;
import gem.database.Database;
import gem.model.core.*;

/*
 *  Abstraktna klasa DAOFActory. Konkretan Factory ce morati
 *  da implementira ove metode u zavisnosti od tipa baze. Imamo samo Mysql, ali nikad se ne zna :)
 */
public abstract class DAOFactory
{
	public static final int MYSQL = 1;
	
	public abstract CourseDAO getCourseDAO();
	public abstract ScienceDomainDAO getScienceDomainDAO();
	public abstract DepartmentDAO getDepartmentDAO();
        
	
	private static DAOFactory mysqlFactory = null;
        
	public static DAOFactory getDAOFactory( int what )
	{
		switch( what )
		{
		case MYSQL:
			//TODO: Add static variable, not create every time
                    mysqlFactory = MySqlDAOFactory.getInstance();
                    return mysqlFactory;
		default:
                    return null;
		}
	}
        
	public static DAOFactory getDAOFactory()
        {
            if( mysqlFactory == null )
            {
                //Database.getConnection().close();
                mysqlFactory = MySqlDAOFactory.getInstance();
            }
            return mysqlFactory;
        }
}
